<?php
namespace ImiDemo\HttpDemo\MainServer\Model;

use Imi\Model\Model;
use Imi\Model\Annotation\Table;
use Imi\Model\Annotation\Column;
use Imi\Model\Annotation\Entity;
use Imi\Model\Annotation\Relation\JoinTo;
use Imi\Model\Annotation\Relation\AutoSave;
use Imi\Model\Annotation\Relation\AutoDelete;
use Imi\Model\Annotation\Relation\AutoInsert;
use Imi\Model\Annotation\Relation\AutoUpdate;
use Imi\Model\Annotation\Relation\JoinToMiddle;
use Imi\Model\Annotation\Relation\JoinFromMiddle;
use Imi\Model\Annotation\Relation\PolymorphicOneToMany;
use Imi\Model\Annotation\Relation\PolymorphicManyToMany;

/**
 * Article
 * @Entity
 * @Table(name="tb_article", id={"id"})
 * @property int $id
 * @property string $title
 * @property string $content
 * @property \Imi\Util\ArrayList $comments
 * @property \Imi\Util\ArrayList $taggables
 * @property \Imi\Util\ArrayList $tags
 */
class Article extends Model
{
	/**
	 * id
	 * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true)
	 * @var int
	 */
	protected $id;

	/**
	 * 获取 id
	 *
	 * @return int
	 */ 
	public function getId()
	{
		return $this->id;
	}

	/**
	 * 赋值 id
	 * @param int $id id
	 * @return static
	 */ 
	public function setId($id)
	{
		$this->id = $id;
		return $this;
	}

	/**
	 * title
	 * @Column(name="title", type="varchar", length=32, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
	 * @var string
	 */
	protected $title;

	/**
	 * 获取 title
	 *
	 * @return string
	 */ 
	public function getTitle()
	{
		return $this->title;
	}

	/**
	 * 赋值 title
	 * @param string $title title
	 * @return static
	 */ 
	public function setTitle($title)
	{
		$this->title = $title;
		return $this;
	}

	/**
	 * content
	 * @Column(name="content", type="text", length=0, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
	 * @var string
	 */
	protected $content;

	/**
	 * 获取 content
	 *
	 * @return string
	 */ 
	public function getContent()
	{
		return $this->content;
	}

	/**
	 * 赋值 content
	 * @param string $content content
	 * @return static
	 */ 
	public function setContent($content)
	{
		$this->content = $content;
		return $this;
	}

	/**
     * 评论
     * 
     * @PolymorphicOneToMany(model=ImiDemo\HttpDemo\MainServer\Model\Comment::class, type="type", typeValue=1)
     * @JoinTo("relation_id")
     * @AutoSave(orphanRemoval=true)
     * @AutoDelete
     *
     * @var \Imi\Util\ArrayList
     */
    protected $comments;

    /**
     * Get 评论
     *
     * @return  \ImiDemo\HttpDemo\MainServer\Model\Comment[]
     */ 
    public function getComments()
    {
        return $this->comments;
    }

    /**
     * Set 评论
     *
     * @param  \ImiDemo\HttpDemo\MainServer\Model\Comment[]  $comments  评论
     *
     * @return  self
     */ 
    public function setComments($comments)
    {
        $this->comments = $comments;

        return $this;
	}
	
    /**
	 * 标签关联
	 * 
     * @PolymorphicManyToMany(model="Tags", middle="Taggables", rightMany="tags", type="taggable_type", typeValue=1)
     * @JoinToMiddle(field="id", middleField="taggable_id")
     * @JoinFromMiddle(middleField="tag_id", field="id")
     * 
     * @AutoInsert
     * @AutoUpdate(orphanRemoval=true)
     * @AutoSave
     * @AutoDelete
     *
     * @var \Imi\Util\ArrayList
     */
	protected $taggables;

	/**
	 * Get 标签关联
	 *
	 * @return  \Imi\Util\ArrayList
	 */ 
	public function getTaggables()
	{
		return $this->taggables;
	}

	/**
	 * Set 标签关联
	 *
	 * @param  \Imi\Util\ArrayList  $taggables  标签关联
	 *
	 * @return  self
	 */ 
	public function setTaggables(\Imi\Util\ArrayList $taggables)
	{
		$this->taggables = $taggables;

		return $this;
	}

	/**
	 * 关联标签
	 *
	 * @var \Imi\Util\ArrayList
	 */
	protected $tags;

	/**
	 * Get 关联标签
	 *
	 * @return  \Imi\Util\ArrayList
	 */ 
	public function getTags()
	{
		return $this->tags;
	}

	/**
	 * Set 关联标签
	 *
	 * @param  \Imi\Util\ArrayList  $tags  关联标签
	 *
	 * @return  self
	 */ 
	public function setTags($tags)
	{
		$this->tags = $tags;

		return $this;
	}
}